<template>
	<view>
		<view class='test' v-for="(item,index) in examinationList">
			<view class='test_answer shad' v-if="item.examStatus!=1 && item.examStatus!=2">
				<text class='test_answer_title'>{{item.examPaperName}}</text>
				<text class='test_answer_content'>{{item.examType==1?'普通测验':'正式测验'}}</text>
				<u-button class='test_answer_btn' size="middle" type="primary" text="开始答题" shape="circle"
					@click="examination(1,index)"></u-button>
			</view>
			<view class='test_answer shad' v-if="item.examStatus==1">
				<text class='test_answer_title'>{{item.examPaperName}}</text>
				<text class='test_answer_content'>{{item.examType==1?'普通测验':'正式测验'}}</text>
				<u-button class='test_answer_btn' size="middle" type="info" text="继续答题" shape="circle"
					@click="examination(1,index)"></u-button>
			</view>
			<view class='shad' v-if="item.examStatus==2">
				<view class='test_answer' style='border-bottom:1px  #F2F2F2 solid'>
					<text class='test_answer_title'>{{item.examPaperName}}</text>
					<text class='test_answer_content'>{{item.examType==1?'普通测验':'正式测验'}}</text>
					<!-- <text class='test_answer_content'>共60道题</text> -->
					<u-button class='test_answer_btn' type="warning" text="再次挑战" shape="circle"
						@click="examination(2,index)">
					</u-button>
				</view>
				<view class='test_result'>
					<text style='color:#151C2A'>
						{{item.endExamTime}} {{item.score}}分
					</text>
					<u-button class='test_answer_btn' type="success" text="查看结果" shape="circle"
						@click="examination(3,index)">
					</u-button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				examinationList: {}
			};
		},
		mounted() {
			this.search()
		},
		onLoad(options) {
			this.search() //刷新数据
		},
		methods: {
			search() {
				this.$api.getTestList({
					"current": 1,
					"size": 99999
				}).then(res => {
					this.examinationList = res.data.data.records
				})
			},
			// 开始答题
			examination(item, index) {
				this.$goBack('../on-line-study/answer?name=' + item + '&classId=' + this.examinationList[index].classId +
					'&examPaperId=' +
					this.examinationList[index].examPaperId + '&examRecordId=' + this.examinationList[index]
					.examRecordId, 2);
			}
		},
	}
</script>


<style lang="scss" scoped>
	.test {
		border-top: 1px #F2F2F2 solid;
		padding: 10px 15px;
		margin: 10px 0 0 0;

		// 开始答题/再次挑战
		.test_answer {
			padding: 10px 0;
			position: relative;

			.test_answer_title {
				width: 60%;
				font-size: 32rpx;
				display: block;
				margin: 15px 0;
				padding: 0 0 0 15px;
				border-left: 2px #FFBC00 solid;
			}

			.test_answer_content {
				padding: 0 0 0 15px;
				color: #7E8EAA;
			}


			.test_answer_time {
				border: 1px red solid;
				display: block;
			}

		}

		// 查看结果
		.test_result {
			padding: 20px 15px;
			position: relative;

		}

		// 按钮
		.test_answer_btn {
			width: 30%;
			position: absolute;
			right: 20rpx;
			top: 50%;
			transform: translate(0, -50%);
		}

		// 阴影
		.shad {
			box-shadow: 4px 4px 6px #F2F2F2;
		}
	}
</style>
